// 统一请求路径前缀在libs/axios.js中修改
import { getRequest, postRequest, putRequest, getNoAuthRequest, postNoAuthRequest } from '@/libs/axios';

/**
 * 获取所有部门列表
 */
export const getOrganization = () => {
  return getNoAuthRequest(`/organization/all`)
}
/**
 * 判断用户是否激活
 * @param {String} mobile 
 */
export const getUserIsActivated = (mobile) => {
  return postNoAuthRequest(`/users/isActivated`, {mobile})
}
/**
 * 登录
 * @param {Object} params 
 * {
 *    organization_id,
 *    mobile,
 *    password
 * }
 */
export const login = (params) => {
  return postNoAuthRequest('/login', params)
}
/**
 * 由用户id获取用户信息
 */
export const getUserInfo = (params) => {
  return postRequest('/users/userInfo', params)
}
/**
 * 由用户id获取用户权限菜单
 * @param {*} params 
 */
export const getMenuList = (params) => {
  return postRequest(`/permission/user`, params)
}
/**
 * 锁屏解锁，判断输入的密码是否正确
 * @param {} params 
 * {id,password}
 */
export const unlock = (params) => {
  return postRequest(`/users/unlock`, params)
}
/**
 * 
 * @param {获取用户角色数组} params 
 */
export const getUserRole = (params) => {
  return postRequest(`/users/userRole`, params)
}

/**
 * 修改密码，登录后的操作，不需要手机验证码
 * @param {} params 
 */
export const changePassword = (params) => {
  return postRequest(`/users/changePassword`, params)
}
/**
 * 激活帐号
 * @param {} params 
 */
export const activate = (params) => {
  return postNoAuthRequest('/users/activate', params)
}
// 重设用户是否激活
export const setActivated = (params) => {
  return postNoAuthRequest('/users/setActivated', params)
}
// 分页获取用户列表
export const getUserList = (params) => {
  return postRequest('/users/getUserList', params)
}
// 分页获取所有用户角色列表
export const getAllRoleList = (params) => {
  return postRequest('/role/getAllList', params)
}
// 获取所有用户角色
export const getAllRoles = () => {
  return postRequest('/role/getAllRoles')
}

// 用户注册
export const register = (params) => {
  return postRequest('/users/register', params)
}
// 按user_id删除角色
export const deleteRoleByUserId = (params) => {
  return postRequest('/userRole/destroyByUserId', params)
}
// 创建用户对应的角色
export const createUserRole = (params) => {
  return postRequest('/userRole/insert', params)
}
// 更新用户信息
export const updateUser = (params) => {
  return postRequest('/users/update', params)
}
// 根据userId获取角色
export const getRoleByUserId = (params) => {
  return postRequest('/userRole/getRoleByUserId', params)
}

export const getAllUserList = () => {
  return postRequest('/users/getAllUserList')
}

export const getCompanyInfo = () => {
  return postNoAuthRequest('/company')
}